using System.IO;
using lucere.io.concurrency;
using lucere.test.io.concurrency.mock;
using MbUnit.Framework;

namespace lucere.test.io.concurrency
{
	[TestFixture]
	public class LockTest
	{
		[Test]
		public void can_obtain()
		{
			var @lock = new LockMock();
			Lock.LOCK_POLL_INTERVAL = 10;
			try
			{
				@lock.Obtain(Lock.LOCK_POLL_INTERVAL);
				Assert.Fail("Should have failed to obtain lock");
			}
			catch (IOException e)
			{
				Assert.AreEqual(@lock.lockAttempts, 2, "should attempt to lock more than once");
			}
		}
	}
}